﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Menu.Master" AutoEventWireup="true" CodeBehind="PackingDetalle.aspx.cs" Inherits="Emporium_Web.PackingDetalle" Theme="Constellation" %>

<%@ MasterType VirtualPath="~/Menu.master" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>

<%@ Register src="Search/PedidoCompraSearch.ascx" tagname="PedidoCompraSearch" tagprefix="uc1" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <script type="text/javascript" src="js/funciones.grid.js"></script>          
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <!-- Content -->
    <article class="container_12">
	  
		<section class="grid_12">
			<div class="block-border">
			<form runat="server" class="block-content form" id="table_form">
				<h1>Packing List</h1>
                 <ajaxtoolkit:toolkitscriptmanager ID="toolk" runat="server"  EnableScriptGlobalization="true" EnableScriptLocalization="true" EnablePageMethods="true"></ajaxtoolkit:toolkitscriptmanager>
                
                <asp:UpdatePanel ID="upnOrdenCorte" runat="server">
                <ContentTemplate>  
             
                <ul class="message warning no-margin" runat="server"  id="warningMessage">
					<li><asp:Label runat="server" ID="lblWarningMessage"></asp:Label></li>
				</ul>
                <ul class="message error no-margin" runat="server" id="errorMessage">
                    <li>
                        <asp:Label runat="server" ID="lblErrorMessage"></asp:Label></li>
                </ul>    

             <%--    <ajaxtoolkit:TabContainer ID="tbcDatosGenerales" runat="server" ActiveTabIndex="0">
                 <ajaxtoolkit:TabPanel ID="TabPanel1" runat="server">
                 <HeaderTemplate>Datos Generales</HeaderTemplate>
                 <ContentTemplate>--%>                 

             <%--   </ContentTemplate>
                </ajaxtoolkit:TabPanel>


               
                 <ajaxtoolkit:TabPanel ID="TabPanel2" runat="server">
                <HeaderTemplate>Cajas</HeaderTemplate>
                <ContentTemplate>--%>

                <fieldset
                 <br /><br />
                 <div style="width:75%; float:left;" align="left">                    
                     <label>Cajas</label>
					 <asp:GridView ID="gvCajas" runat="server" SkinID="gridviewSkin" 
                             PageSize="10" Width="100%"
                            AutoGenerateColumns="False" ShowFooter="True" 
                         DataKeyNames = "PacCaj_Secuencia,PacCaj_Id" onrowcommand="gvCajas_RowCommand" 
                         onrowdatabound="gvCajas_RowDataBound" onrowdeleting="gvCajas_RowDeleting" onselectedindexchanged="gvCajas_SelectedIndexChanged"
                         >
                        <HeaderStyle Font-Bold="True"/>                     
                        <Columns>                            
                             
                             <asp:CommandField ButtonType="Image" SelectImageUrl="~/images/unselected.png" ShowSelectButton="True" >
                                <HeaderStyle/>
                            </asp:CommandField>
                                 
                             <asp:TemplateField HeaderText="Secuencia"  HeaderStyle-HorizontalAlign="Left">
                                <FooterTemplate>
                                    <asp:Label ID="lblSecuenciaId" runat="server"></asp:Label> 
                                 </FooterTemplate>                                                                                           
                                <ItemTemplate> 
                                    <asp:Label ID="lblSecuencia" runat="server" Text='<%# Bind("PacCaj_Secuencia","{0:000}") %>'></asp:Label> 
                                </ItemTemplate> 
                                <ItemStyle Width="10%" />
                            </asp:TemplateField>

                             <asp:TemplateField HeaderText="Caja"  HeaderStyle-HorizontalAlign="Left">
                                <FooterTemplate>
                                    <asp:Label ID="lblCajaId" runat="server"></asp:Label> 
                                 </FooterTemplate>                                                                                           
                                <ItemTemplate> 
                                    <asp:Label ID="lblCaja" runat="server" Text='<%# Bind("PacCaj_Id","{0:00000}") %>'></asp:Label> 
                                </ItemTemplate> 
                                <ItemStyle Width="10%" />
                            </asp:TemplateField>
                                                
                           <asp:TemplateField HeaderText="Orden.Prod" HeaderStyle-HorizontalAlign="Left">                                 
                                <FooterTemplate>                                     
                                    <asp:DropDownList ID="ddlOrdenProduccionNew" runat="server" Width="200px" AutoPostBack="true" OnSelectedIndexChanged ="ddlOrdenProduccion_SelectedIndexChanged"></asp:DropDownList>                                                                         
                                </FooterTemplate> 
                                <ItemTemplate> 
                                    <asp:Label ID="lblOrdenProduccion" runat="server" Text='<%# Bind("OrdPro_Id","{0:00000}") %>'></asp:Label>                                     
                                </ItemTemplate> 
                                <ItemStyle Width="25%" />
                            </asp:TemplateField>
                                            
                           <asp:TemplateField HeaderText="Estilo" HeaderStyle-HorizontalAlign="Left">                                 
                                <FooterTemplate>                                     
                                    <asp:DropDownList ID="ddlEstiloNew" runat="server" Width="200px"></asp:DropDownList>                                                                         
                                </FooterTemplate> 
                                <ItemTemplate> 
                                    <asp:Label ID="lblEstilo" runat="server" Text='<%# Bind("Estilo_Id","{0:00000}") %>'></asp:Label>                                     
                                </ItemTemplate> 
                                <ItemStyle Width="25%" />
                            </asp:TemplateField>                          

                            <asp:TemplateField HeaderText="Prendas" HeaderStyle-HorizontalAlign="Left">                                 
                                <FooterTemplate>                                     
                                    <asp:TextBox ID="txtPrendasNew" runat="server" Width="120px" MaxLength="3"></asp:TextBox>                                     
                                    <asp:RequiredFieldValidator ID="reqPrendasNew" runat="server" ControlToValidate="txtPrendasNew" Text="Valor requerido" ValidationGroup ="AgregarCaja"></asp:RequiredFieldValidator>
                                </FooterTemplate> 
                                <ItemTemplate> 
                                    <asp:Label ID="lblPrendas" runat="server" style=" display:none;" Text='<%# Eval("PacCaj_Prendas") %>'></asp:Label> 
                                    <asp:TextBox ID="txtPrendas" runat="server" Width="120px" MaxLength="3" onKeyPress ='return ValidarInputNumerico(event)' onChange='ActualizarPrendas(event,this)' Text='<%# Eval("PacCaj_Prendas") %>' ></asp:TextBox>
                                </ItemTemplate> 
                                <ItemStyle Width="25%" />
                            </asp:TemplateField>

                              <asp:TemplateField HeaderText="Peso Bruto" HeaderStyle-HorizontalAlign="Left">                                 
                                <FooterTemplate>                                     
                                    <asp:TextBox ID="txtPesoNew" runat="server" Width="120px" MaxLength="3"></asp:TextBox>                                     
                                    <asp:RequiredFieldValidator ID="reqPesoNew" runat="server" ControlToValidate="txtPesoNew" Text="Valor requerido" ValidationGroup ="AgregarCaja"></asp:RequiredFieldValidator>
                                </FooterTemplate> 
                                <ItemTemplate> 
                                    <asp:Label ID="lblPeso" runat="server" style=" display:none;" Text='<%# Eval("PacCaj_PesoBruto") %>'></asp:Label> 
                                    <asp:TextBox ID="txtPeso" runat="server" Width="120px" MaxLength="3" onKeyPress ='return ValidarInputDecimal(event)' onChange='ActualizarPeso(event,this)' Text='<%# Eval("PacCaj_PesoBruto") %>' ></asp:TextBox>
                                </ItemTemplate> 
                                <ItemStyle Width="25%" />
                            </asp:TemplateField>

                             <asp:TemplateField HeaderText="Estado" HeaderStyle-HorizontalAlign="Left"> 
                                <ItemTemplate> 
                                    <asp:Label ID="lblEstado" runat="server" Text='<%# Bind("PacCaj_Estado") %>'></asp:Label> 
                                </ItemTemplate> 
                                <ItemStyle Width="10%" />
                            </asp:TemplateField>
                            
                            <asp:TemplateField ShowHeader="False" HeaderStyle-HorizontalAlign="Left">                                
                                <FooterTemplate> 
                                    <asp:ImageButton ID="imgAdd" runat="server" CausesValidation="True" CommandName="Insert" ValidationGroup = "AgregarCaja" ImageUrl="~/images/icons/web-app/24/Save.png" ToolTip ="Agregar"></asp:ImageButton> 
                                </FooterTemplate> 
                                 <ItemTemplate> 
                                    <asp:ImageButton ID="imgDelete" runat="server" CausesValidation="False" CommandName="Delete"  ImageUrl="~/images/icons/web-app/24/Delete.png" OnClientClick="return DeleteRegistro();" ToolTip="Eliminar"></asp:ImageButton> 
                                </ItemTemplate>                               
                                 <ItemStyle Width="2%" />
                            </asp:TemplateField>     
                                                 
						</Columns>  						
					</asp:GridView>                    
                    
                </div>				


                   <br /><br />
                 <div style="width:75%; float:left;" align="left">                    
                     <label>Prendas</label>
					 <asp:GridView ID="gvPrendas" runat="server" SkinID="gridviewSkin" 
                             PageSize="10" Width="100%"
                            AutoGenerateColumns="False" ShowFooter="True" 
                         DataKeyNames = "OrdPro_Id,Estilo_Id" onrowcommand="gvPrendas_RowCommand" 
                         onrowdatabound="gvPrendas_RowDataBound" onrowdeleting="gvPrendas_RowDeleting"
                         >
                        <HeaderStyle Font-Bold="True"/>                     
                        <Columns>                            
                             
                             <asp:CommandField ButtonType="Image" SelectImageUrl="~/images/unselected.png" ShowSelectButton="True" >
                                <HeaderStyle/>
                            </asp:CommandField>   

                           <asp:TemplateField HeaderText="Orden.Prod" HeaderStyle-HorizontalAlign="Left">                                                                 
                                <ItemTemplate> 
                                    <asp:Label ID="lblOrdenProduccion" runat="server" Text='<%# Bind("OrdPro_Id","{0:00000}") %>'></asp:Label>                                     
                                </ItemTemplate> 
                                <ItemStyle Width="25%" />
                            </asp:TemplateField>
                                            
                            <asp:TemplateField HeaderText="Estilo" HeaderStyle-HorizontalAlign="Left">                                                               
                                <ItemTemplate> 
                                    <asp:Label ID="lblEstilo" runat="server" Text='<%# Bind("Estilo_Id","{0:00000}") %>'></asp:Label>                                     
                                </ItemTemplate> 
                                <ItemStyle Width="25%" />
                            </asp:TemplateField> 
                            
                            <asp:TemplateField HeaderText="Etiqueta" HeaderStyle-HorizontalAlign="Left">                                 
                                <FooterTemplate>                                     
                                    <asp:DropDownList ID="ddlEtiquetaNew" runat="server" Width="200px" OnSelectedIndexChanged ="ddlEtiqueta_SelectedIndexChanged" AutoPostBack="true"></asp:DropDownList>                                                                         
                                </FooterTemplate> 
                                <ItemTemplate> 
                                    <asp:Label ID="lblEtiqueta" runat="server" Text='<%# Bind("PacPre_Etiqueta","{0:00000}") %>'></asp:Label>                                     
                                </ItemTemplate> 
                                <ItemStyle Width="25%" />
                            </asp:TemplateField>                          

                            <asp:TemplateField HeaderText="Talla" HeaderStyle-HorizontalAlign="Left">                                 
                                <FooterTemplate>                                     
                                    <asp:DropDownList ID="ddlTallaNew" runat="server" Width="200px"></asp:DropDownList>                                                                         
                                </FooterTemplate> 
                                <ItemTemplate> 
                                    <asp:Label ID="lblTalla" runat="server" Text='<%# Bind("PacPre_Talla","{0:00000}") %>'></asp:Label>                                     
                                </ItemTemplate> 
                                <ItemStyle Width="25%" />
                            </asp:TemplateField> 

                            <asp:TemplateField HeaderText="Prendas" HeaderStyle-HorizontalAlign="Left">                                 
                                <FooterTemplate>                                     
                                    <asp:TextBox ID="txtPrendasNew" runat="server" Width="120px" MaxLength="3"></asp:TextBox>                                     
                                    <asp:RequiredFieldValidator ID="reqPrendasNew" runat="server" ControlToValidate="txtPrendasNew" Text="Valor requerido" ValidationGroup ="AgregarPrenda"></asp:RequiredFieldValidator>
                                </FooterTemplate> 
                                <ItemTemplate> 
                                    <asp:Label ID="lblPrendas" runat="server" style=" display:none;" Text='<%# Eval("PacPre_Prendas") %>'></asp:Label> 
                                    <asp:TextBox ID="txtPrendas" runat="server" Width="120px" MaxLength="3" onKeyPress ='return ValidarInputNumerico(event)' onChange='ActualizarPrendas(event,this)' Text='<%# Eval("PacPre_Prendas") %>' ></asp:TextBox>
                                </ItemTemplate> 
                                <ItemStyle Width="25%" />
                            </asp:TemplateField>                           
                            
                            <asp:TemplateField ShowHeader="False" HeaderStyle-HorizontalAlign="Left">                                
                                <FooterTemplate> 
                                    <asp:ImageButton ID="imgAdd" runat="server" CausesValidation="True" CommandName="Insert" ValidationGroup = "AgregarPrenda" ImageUrl="~/images/icons/web-app/24/Save.png" ToolTip ="Agregar"></asp:ImageButton> 
                                </FooterTemplate> 
                                 <ItemTemplate> 
                                    <asp:ImageButton ID="imgDelete" runat="server" CausesValidation="False" CommandName="Delete"  ImageUrl="~/images/icons/web-app/24/Delete.png" OnClientClick="return DeleteRegistro();" ToolTip="Eliminar"></asp:ImageButton> 
                                </ItemTemplate>                               
                                 <ItemStyle Width="2%" />
                            </asp:TemplateField>     
                                                 
						</Columns>  						
					</asp:GridView>                    
                    
                </div>		
                    
                </fieldset>			                

              <%--  </ContentTemplate>
                </ajaxtoolkit:TabPanel>               
             

                 </ajaxtoolkit:TabContainer>--%>

                 <br />
                 <fieldset class="grey-bg no-margin">
				<br />
                        <asp:LinkButton ID="btnAtras" runat="server" CssClass="button red" 
                        Text="Atrás" CausesValidation="false" onclick="btnAtras_Click"></asp:LinkButton>
				</fieldset>

                </ContentTemplate>
                </asp:UpdatePanel>


			</form>
			</div>
		</section>
	</article>  

    <script type="text/javascript">

        function ActualizarPrendas(e, txt) {
            PageMethods.ActualizarPrendas($(txt).parent()[0].children[0].innerHTML, $(txt).parent()[0].children[1].value);          
            return false;
        }

        function ActualizarPeso(e, txt) {
            PageMethods.ActualizarPeso($(txt).parent()[0].children[0].innerHTML, $(txt).parent()[0].children[1].value);
            return false;
        }        

        function ValidarInputNumerico(e) {
            var valid = "0123456789"
            return ValidaInput(valid, e);
        }
        
        function ValidarInputDecimal(e) {
            var valid = "0123456789.";
            return ValidaInput(valid, e);

        }

        function ValidaInput(valid, e) {
            var keyAscii = (document.all) ? event.keyCode : e.which;
            if (keyAscii != 13) {
                var key = String.fromCharCode(keyAscii);
                var keyAj = key.toUpperCase();
                if (valid == '') {
                    return true;
                }
                if (valid.indexOf(keyAj) == "-1") {
                    if (keyAscii != 8 && keyAscii != 0) { return false };
                    return true;
                }
                return true;
            }
        }

    </script>
</asp:Content>
